import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   如果true，此侧边栏将一直显示，默认为false
* alwaysShow: true               如果为true，默认主菜单，如果不设置alwaysshow
*                                如果子路由超过一个，将成为嵌套菜单
* redirect: noredirect           如果设置redirect:noredirect` 不将重定向面包屑
* name:'router-name'             路由名字必须填写
* meta : {
    title: 'title'               菜单名字
    icon: 'svg-name'             菜单图标（svg）格式
  }
* constantRouterMap 数组下配置的为默认路由，不需要权限配置
* asyncRouterMap 数组下配置的路由需要权限认证，meta ：{ roles: [] } //roles内必须为数组！
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true }, // 登录页面
  { path: '/404', component: () => import('@/views/404'), hidden: true }, // 404
  { // 默认路由页
    path: '/',
    component: Layout,
    redirect: '/search/allData',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/actionManage',
    component: Layout,
    hidden: true,
    meta: { roles: 'integralTrigger' },
    children: [{
      path: 'index/:code/:power',
      name: 'ActionManage',
      component: () => import('@/views/pointChange/components/actionManage'),
      meta: { title: '动作管理', icon: 'point' }
    }]
  }
  // {
  //   path: '/actionManage/:id',
  //   meta: { roles: 'querycollect' },
  //   component: () => import('@/views/pointChange/components/actionManage')
  // }
]
export const asyncRouterMap = [
  // 查询汇总
  {
    path: '/search',
    component: Layout,
    meta: { roles: ['search', 'sunData'], title: '全网用户汇总', icon: 'salungeng' },
    children: [{
      path: 'index',
      name: 'Search',
      component: () => import('@/views/search/newIndex'),
      meta: { roles: ['search'], title: '用户管控', icon: 'settings' }
    }, {
      path: 'allData',
      name: 'AllData',
      component: () => import('@/views/search/chart'),
      meta: { roles: ['sunData'], title: '中心概要', icon: 'pingtai' }
    }]
  },
  // 联通
  {
    path: '/liantong',
    component: Layout,
    alwaysShow: true,
    meta: { roles: 'allData' },
    children: [{
      path: 'index',
      name: 'Liantong',
      component: () => import('@/views/liantong/index'),
      meta: { title: '联通', icon: 'liantong' }
    }]
  },
  /* // 平台管理
  {
    path: '/platformManage',
    component: Layout,
    hidden: true,
    meta: { roles: 'platformManage' },
    children: [{
      path: 'index',
      name: 'PlatformManage',
      component: () => import('@/views/platformManage/index'),
      meta: { title: '平台管理', icon: 'pingtai' }
    }]
  }, */
  // 积分触发管理
  {
    path: '/pointChangeManager',
    component: Layout,
    meta: { roles: 'point' },
    children: [{
      path: 'index',
      name: 'PointChangeManager',
      component: () => import('@/views/pointChange/index'),
      meta: { title: '积分触发管理', icon: 'point' }
    }]
  },
  // 会员管理
  {
    path: '/vipManage',
    component: Layout,
    meta: { roles: 'vip' },
    children: [{
      path: 'index',
      name: 'VipManage',
      component: () => import('@/views/vipManage/index'),
      meta: { title: '会员管理', icon: 'vipp' }
    }]
  },
  // 角色管理
  /* {
    path: '/partManage',
    component: Layout,
    hidden: true,
    meta: { roles: 'roleManage' },
    children: [{
      path: 'index',
      name: 'PartManage',
      component: () => import('@/views/partManage/index'),
      meta: { title: '角色管理', icon: 'jueseguanli' }
    }]
  }, */
  // 用户管理
  /* {
    path: '/userManage',
    component: Layout,
    hidden: true,
    meta: { roles: 'userManage' },
    children: [{
      path: 'index',
      name: 'UserManage',
      component: () => import('@/views/userManage/index'),
      meta: { title: '用户管理', icon: 'user' }
    }]
  }, */
  // 操作日志
  /* {
    path: '/log',
    hidden: true,
    component: Layout,
    meta: { roles: 'operationManage' },
    children: [{
      path: 'index',
      name: 'Log',
      component: () => import('@/views/log/index'),
      meta: { title: '操作日志', icon: 'rizhi' }
    }]
  }, */
  { path: '*', meta: { roles: '' }, redirect: '/404', hidden: true }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
